/*
 * @lc app=leetcode.cn id=641 lang=cpp
 *
 * [641] 设计循环双端队列
 */

// @lc code=start
#include <bits/stdc++.h>
using namespace std;
class MyCircularDeque
{
    deque<int> q;
    int max_size = 0;

public:
    MyCircularDeque(int k)
    {
        max_size = k;
    }

    bool insertFront(int value)
    {
        if (q.size() == max_size)
            return false;
        q.push_front(value);
        return true;
    }

    bool insertLast(int value)
    {
        if (q.size() == max_size)
            return false;
        q.push_back(value);
        return true;
    }

    bool deleteFront()
    {
        if (q.size())
        {
            q.pop_front();
            return true;
        }
        return false;
    }

    bool deleteLast()
    {
        if (q.size())
        {
            q.pop_back();
            return true;
        }
        return false;
    }

    int getFront()
    {
        if(q.empty()) return -1;
        return q.front();
    }

    int getRear()
    {
        if(q.empty()) return -1;
        return q.back();
    }

    bool isEmpty()
    {
        return q.empty();
    }

    bool isFull()
    {
        return q.size() == max_size;
    }
};

/**
 * Your MyCircularDeque object will be instantiated and called as such:
 * MyCircularDeque* obj = new MyCircularDeque(k);
 * bool param_1 = obj->insertFront(value);
 * bool param_2 = obj->insertLast(value);
 * bool param_3 = obj->deleteFront();
 * bool param_4 = obj->deleteLast();
 * int param_5 = obj->getFront();
 * int param_6 = obj->getRear();
 * bool param_7 = obj->isEmpty();
 * bool param_8 = obj->isFull();
 */
// @lc code=end
